#!/bin/sh
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.


#
# usage: fixtabs file ...
# convert tabs to spaces and strip trailing whitespace, but ignore lines of
# pure whitespace (XCode likes to insert these and MMgc is riddled with them).
# See bug 600536 for some context on this.
#
# example usage to fix all files that contain the VIM space-only modelines (expandtab):
# fixtabs `grep -l expandtab *`
#

for file in $*; do
	cp $file $file.tmp
	expand -4 <$file.tmp | perl -p -e 's/(\S)\s+\n$/\1\n/go;' >$file
	rm $file.tmp
done
